import { getSongPlayUrl } from '../utils/common-fn'

export default function useMusicPlay() {
  const audio = document.createElement('audio')
  audio.src = getSongPlayUrl()
  const setSrc = (id) => {
    audio.src = getSongPlayUrl(id)
  }
  const pause = () => {
    audio.pause()
  }
  const play = async () => {
    await audio.play()
  }
  return {
    setSrc,
    pause,
    play
  }
}
